package com.wyy.springbootgraphql.resolver;

import com.wyy.springbootgraphql.beans.Book;
import graphql.kickstart.tools.GraphQLQueryResolver;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;


//@Service
public class BookQueryResolver implements GraphQLQueryResolver {

    public Book bookById(String id){
        if ("test01".equals(id)){
            Book book = new Book();
            book.setId("book01");
            book.setName("nameId01");
            return book;
        } else
            return null;
    }

    public Book bookByName(String name){
        if ("book1".equals(name)){
            Book book = new Book();
            book.setId("book01");
            book.setName("name01");
            return book;
        }else
            return null;
    }

    public List<Book> getBooks(){
        ArrayList<Book> books = new ArrayList<>();
        Book book = new Book();
        book.setId("1");
        books.add(book);
        books.add(book);
        books.add(book);
        books.add(book);
        books.add(book);
        return books;
    }
}
